#############################
## BLIS/Swayable: Figure 1 ##
#############################

# File Description: 
# Uses data/packages from O_Data.R
# Replicates Figure 1 from Fabric of Repair report (2025)
# Date Last Updated: 2 May 2025

#############################

# Create summary dataframe for Reparations baseline
df_bn_repbaseline_plot <- 
  df %>% 
  group_by(race_single) %>% 
  count(rep_baseline_categorical) %>% 
  mutate(Percentage = n/sum(n) * 100) %>% 
  rename(baseline_support = rep_baseline_categorical) %>% 
  add_column(Movement = "Reparations")

# Create summary dataframe for Land Back baseline
df_bn_landbackbaseline_plot <- 
  df %>% 
  group_by(race_single) %>% 
  count(landback_baseline_categorical) %>% 
  mutate(Percentage = n/sum(n) * 100) %>% 
  rename(baseline_support = landback_baseline_categorical) %>% 
  add_column(Movement = "Land Back")

# Merge summary dataframes for Reparations and Land Back
df_bn_baselinesupport_plot <- bind_rows(df_bn_repbaseline_plot, df_bn_landbackbaseline_plot)

# Plot Figure 1
df_bn_baselinesupport_plot %>% 
  mutate(race_label = case_when(race_single == "black-or-african-american" ~ "Black Respondent",
                                race_single == "american-indian-or-alaska-native" ~ "Native Respondent"))  %>%
  ggplot(aes(x = baseline_support, y = Percentage, fill = Movement)) +
  geom_bar(stat = "identity", position = "dodge") +
  labs(title = "Baseline Support for Each Movement",
       x = "Baseline Support",
       y = "Percentage",
       fill = "Movement") +  scale_y_continuous(labels = scales::percent_format(scale = 1)) +
  scale_fill_manual(values = c("#1DA595", "#F94B01")) + 
  facet_wrap(~race_label) + 
  theme_bw()